﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Common;

public partial class website_admin_sales_ordersettings : PageBase
{
    public string TotalPrice = "", OrderTypeCode = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = -1;
        PageBegin();

        if (!IsPostBack)
        {
            if (RequestBase.GetQueryString("orderid") != "")
            {
                InitializeOrderObj();
            }
        }
    }
    void InitializeOrderObj()
    {
        string result = "";
        Model.OrderBase _order = BLL.OrderBase.GetObjectById(RequestBase.GetQueryString("orderid"), out result);

        if (_order != null)
        {
            OrderTypeCode = _order.OrderTypeCode.ToString();
            spanOrderType.InnerText = _order.OrderTypeCode.ToString().Replace("1", "普通订单").Replace("2", "团购订单"); 
            spanOrderNumber.InnerText = _order.OrderNumber;
            spanOrderDate.InnerText = _order.OrderDate.ToString("yyyy-MM-dd");
            spanTotalPrice.InnerText = _order.TotalPrice.ToString();
            TotalPrice = _order.TotalPrice.ToString();
            spanShipAddress.InnerText = _order.ShipAddress;
            spanShipMobile.InnerText = _order.ShipMobile;
            spanShipTel.InnerText = _order.ShipTel;
            spanShipToName.InnerText = _order.ShipToName;
            spanShipZip.InnerText = _order.ShipZip;
            spanShipCounties.InnerText = _order.ShipState + "．" + _order.ShipCity + "．" + _order.ShipCounties;

            spanInvoiceTitle.InnerText = _order.InvoiceTitle;
            spanPaymentTypeName.InnerText = _order.PaymentType;
            spanComments.InnerText = _order.Comment;

            spanOrderStatus.InnerText = _order.StatusCode.ToString().Replace("-1", "已作废").Replace("0", "未支付").Replace("1", "已付款");

            rptOrderItems.DataSource = BLL.OrderBase.GetItems(RequestBase.GetQueryString("orderid"), out result);
            rptOrderItems.DataBind();
        }
    }
}
